home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / thomas / thomas.lha / Thomas / Thomas-1.1 / src / portable-rep.scm < prev    next >
Text File  |  1992-09-21  |  4KB  |  93 lines

  1. ;*              Copyright 1992 Digital Equipment Corporation
  2. ;*                         All Rights Reserved
  3. ;*
  4. ;* Permission to use, copy, and modify this software and its documentation is
  5. ;* hereby granted only under the following terms and conditions.  Both the
  6. ;* above copyright notice and this permission notice must appear in all copies
  7. ;* of the software, derivative works or modified versions, and any portions
  8. ;* thereof, and both notices must appear in supporting documentation.
  9. ;*
  10. ;* Users of this software agree to the terms and conditions set forth herein,
  11. ;* and hereby grant back to Digital a non-exclusive, unrestricted, royalty-free
  12. ;* right and license under any changes, enhancements or extensions made to the
  13. ;* core functions of the software, including but not limited to those affording
  14. ;* compatibility with other hardware or software environments, but excluding
  15. ;* applications which incorporate this software.  Users further agree to use
  16. ;* their best efforts to return to Digital any such changes, enhancements or
  17. ;* extensions that they make and inform Digital of noteworthy uses of this
  18. ;* software.  Correspondence should be provided to Digital at:
  19. ;*
  20. ;*            Director, Cambridge Research Lab
  21. ;*            Digital Equipment Corp
  22. ;*            One Kendall Square, Bldg 700
  23. ;*            Cambridge MA 02139
  24. ;*
  25. ;* This software may be distributed (but not offered for sale or transferred
  26. ;* for compensation) to third parties, provided such third parties agree to
  27. ;* abide by the terms and conditions of this notice.
  28. ;*
  29. ;* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
  30. ;* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
  31. ;* MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
  32. ;* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  33. ;* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  34. ;* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
  35. ;* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  36. ;* SOFTWARE.
  37.  
  38. ; $Id: portable-rep.scm,v 1.8 1992/09/21 21:30:56 birkholz Exp $
  39.  
  40. ;;; Just use current (user?) environment and keep a list of known module
  41. ;;; variables in thomas-rep-module-variables.
  42.  
  43. (define thomas-rep-module-variables '())
  44.  
  45. (define (empty-thomas-environment!)
  46.   ;; Just dump thomas-rep-module-variables.
  47.   (set! thomas-rep-module-variables '()))
  48.  
  49. (define (thomas-rep)
  50.   (newline)
  51.   (display "Entering Thomas read-eval-print-loop.")
  52.   (newline)
  53.   (display "Exit by typing \"thomas:done\"")
  54.   (newline)
  55.   (dylan::catch-all-conditions
  56.    (lambda ()
  57.      (let loop ()
  58.        (newline)
  59.        (display "? ")
  60.        (let ((input (read)))
  61.      (newline)
  62.      (if (and (eq? input 'thomas:done))
  63.          'thomas:done
  64.          (compile-expression
  65.           input '!MULTIPLE-VALUES thomas-rep-module-variables
  66.           (lambda (new-vars preamble compiled-output)
  67.         (implementation-specific:eval
  68.          `(BEGIN
  69.             ,@preamble
  70.             (LET* ((!MULTIPLE-VALUES (VECTOR '()))
  71.                (!RESULT ,compiled-output))
  72.               (IF (EQ? !RESULT !MULTIPLE-VALUES)
  73.               (LET RESULT-LOOP
  74.                   ((COUNT 1)
  75.                    (RESULTS (VECTOR-REF !MULTIPLE-VALUES 0)))
  76.                 (IF (PAIR? RESULTS)
  77.                 (LET ((RESULT (CAR RESULTS)))
  78.                   (NEWLINE)
  79.                   (DISPLAY ";Value[")(DISPLAY COUNT)
  80.                   (DISPLAY "]: ")(WRITE RESULT)
  81.                   (RESULT-LOOP (+ 1 COUNT) (CDR RESULTS)))
  82.                 (NEWLINE)))
  83.               (BEGIN
  84.                 (NEWLINE)(DISPLAY ";Value: ")(WRITE !RESULT)
  85.                 (NEWLINE))))))
  86.         (set! thomas-rep-module-variables
  87.               (append new-vars thomas-rep-module-variables))
  88.         (loop)))))))))
  89.  
  90. (display "
  91. Apply thomas-rep to start a Thomas read-eval-print loop.
  92. ")
  93.